package cn.tedu.toa.management.sys.controller;


import cn.tedu.toa.management.commons.vo.Result;
import cn.tedu.toa.management.sys.entity.SysMenus;
import cn.tedu.toa.management.sys.service.SysMenusService;
import cn.tedu.toa.management.sys.service.impl.SysMenusServiceImpl;
import cn.tedu.toa.management.sys.vo.MenuNodeVo;
import cn.tedu.toa.management.sys.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 资源管理 前端控制器
 * </p>
 *
 * @author huaqian
 * @since 2021-09-09
 */
@RestController
@RequestMapping("/sys-menus")
public class SysMenusController {
    @Autowired
    private SysMenusService menusService;


    @RequestMapping("/listMenuVo")
    public Result<List<MenuVo>> listMenuVo(){
        List<MenuVo> list= menusService.listMenuVo();
        return Result.ok(list);
    }

    @RequestMapping("/removeMenuById")
    public Result removeMenuById(Integer menuId){
        menusService.removeMenuById(menuId);
        return Result.ok();
    }

    @RequestMapping("/findMenuNodes")
    public Result findMenuNodes(){
        List<MenuNodeVo> list= menusService.findMenuNodes();
        return Result.ok(list);
    }
    @RequestMapping("/saveMenu")
    public Result saveMenu(SysMenus menu){
        menusService.saveMenu(menu);
        return Result.ok();
    }

    @RequestMapping("/findMenuById")
    public Result<MenuVo> selectMenuVo(Integer id){
        MenuVo menuVo=menusService.selectMenuVo(id);
        return Result.ok(menuVo);
    }

    @RequestMapping("/modifySysMenuById")
    public Result modifySysMenuById(SysMenus sysMenus){
        menusService.modifyMenuById(sysMenus);
        return Result.ok();
    }

}
